<!doctype html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title>sharestall 下载</title>
  <meta name="viewport" content="initial-scale=1, maximum-scale=1" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <style>
    * {
      -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    }

    p {
      margin: 0;
    }

    svg path, svg rect {
      fill: #395CF3;
    }
  </style>
</head>

<body style="background: #ffffff">
  <div>
    <div style="position: absolute;top: 0;right: 0;bottom: 0;left: 0;overflow: auto;width: 100%">
      <!-- 这里是页面内容区 -->
      <div style="background: none;height:44%;background-size: cover;position: relative">
        <div style="position: absolute;width:100px;height: 100px;border: 1px solid #e5e5e5;border-radius: 15px;left: 50%;top: 100%;margin-top: -50px;margin-left: -50px;">
      <img class="icon" src="" alt="" style="width: 100px;height: 100px;"/>
      <div style="height:6px;background: rgba(0,0,0,1);opacity: 0.1;text-align: center;border-radius: 50%;margin-top: 5px"></div>
  </div>
      </div>
      <p class="name" style="font-size:2em;margin: 2.3em 0 0.3em;;text-align: center;color: #282828">shareinstall</p>
      <div style="margin: 1.75rem 0;padding: 0 0.75rem;color: #6d6d72;">
        <p>
          <div id="installTip" style="display: none;text-align: center">
            <div id="installTxt" style="display: none;line-height: 40px">正在安装，请按Home键在桌面查看</div>
            <div id="svgCtn">
                <svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
                  <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z" transform="rotate(120.141 25 25)">
                    <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
                  </path>
                </svg>
            </div>
          </div>
          <a href="javascript:;" id="install" style="background:#395CF3;color:#fff;border:1px solid #395CF3;text-align:center;display:block;border-radius:0.25rem;padding:0 0.5rem;margin:0;cursor:pointer;height:3rem;line-height:3rem;text-decoration: none;font-size: 1em">点击下载安装</a>
        </p>
      </div>
    </div>
  </div>
  <script src="https://cdn.bootcss.com/jquery/1.9.0/jquery.min.js"></script>
  <script type="text/javascript">
    function installApp(){
        if(window.navigator.standalone){ // from Home Screen Icon
            // tap Install Button by script
            var event = document.createEvent("MouseEvents");
            event.initEvent("click", true, true);
            document.getElementById("install").dispatchEvent(event);
        }
    }

    function GetRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }

    var $_tmp_par = GetRequest();
    if($_tmp_par.app_key !== undefined){
        var _app_key = $_tmp_par.app_key;
        console.log(_app_key);
        //alert(_app_key);
    }else{
        //alert("app_key is error!");

    }

    // 页面信息渲染
    $.ajax({
      url: 'http://api.shareinstall.com/appliance/getone',
      type: 'POST',
      data: {
        app_key: _app_key || ''
      },
      success: function (res) {
        $('.icon').attr('src', res.data.icon)
        $('.name').text(res.data.name)
      }
    })

    var url = 'https://test-api.shareinstall.com/plists/index';

    var params ='?app_key='+_app_key;
    var encodeParams=encodeURIComponent(params)

    var timer = null


    //var url='https://test-dev.dftoutiao.com/test4/test';
    console.log(url);
    document.getElementById('install').href="itms-services://?action=download-manifest&url="+url+encodeParams;
    document.getElementById('install').onclick = function () {
      this.style.display = 'none'
      document.getElementById('installTip').style.display = 'block'
      clearTimeout(timer)
      timer = setTimeout(function () {
        document.getElementById('installTxt').style.display = 'block'
        document.getElementById('svgCtn').style.display = 'none'
      }, 5000)
    }

</script>
</body>

</html>